﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using GMusicBox.Core;
using GMusicBox.Core.Setting;
using System.IO;

namespace GMusicBox
{
    public partial class frmConfig : Form
    {
        public frmConfig(frmMain fm)
        {
            InitializeComponent();
            Initialize();

            this.fm = fm;
            backgroundWorker1.RunWorkerAsync();
        }

        string[] hotkeys;
        bool initializing = false;
        bool dspRefresh = false;
        frmMain fm;

        private void Initialize()
        {
            initializing = true;
            this.TopMost = Core.Setting.StandardSetting.TopMost;

            chkTopMost.Checked = StandardSetting.TopMost;
            chkAutoStart.Checked = StandardSetting.AutoStart;
            chkSubtitle.Checked = StandardSetting.Subtitle;
            chkShowWelcome.Checked = StandardSetting.ShowWelcome;
            chkShowNowPlaying.Checked = StandardSetting.ShowNowPlaying;
            chkExpanderAnimation.Checked = StandardSetting.ExpanderAnimation;
            chkMinimizeToTray.Checked = StandardSetting.MinimizeToTray;
            chkShowAd.Checked = StandardSetting.ShowAd;
            cboCloseEvent.SelectedIndex = StandardSetting.CloseEvent;

            if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GMusicBox" + "\\true"))
                cboProfileLocation.SelectedIndex = 0;
            else cboProfileLocation.SelectedIndex = 1;

            picDBackColor.BackColor = LyricShowSetting.DBackColor;
            picDBorderColor.BackColor = LyricShowSetting.DBorderColor;
            picDHTextColor.Color0 = LyricShowSetting.DHTextColor;
            picDHTextColor.Color1 = LyricShowSetting.DHTextColor1;
            picDTextColor.Color0 = LyricShowSetting.DTextColor;
            picDTextColor.Color1 = LyricShowSetting.DTextColor1;
            picLBackColor.BackColor = LyricShowSetting.LBackColor;
            picLHTextColor.BackColor = LyricShowSetting.LHTextColor;
            picLTextColor.BackColor = LyricShowSetting.LTextColor;
            cboDLinearMode.SelectedIndex = LyricShowSetting.DLinearMode;
            cboDOpacity.SelectedIndex = cboDOpacity.Items.IndexOf(Math.Round(LyricShowSetting.DOpacity * 100).ToString() + "%");

            chkLFade.Checked = LyricShowSetting.LFade;
            chkDKalaOK.Checked = LyricShowSetting.DKalaOK;
            lnkChooseLFont.Tag = String2Font(LyricShowSetting.LFont);
            lnkChooseDFont.Tag = String2Font(LyricShowSetting.DFont);

            nudCacheMax.Value = StandardSetting.CacheMax;
            txtMusicCache.Text = StandardSetting.CachePath;

            hotkeys = StandardSetting.HotKeys.Split('|');
            for (int i = 0; i < hotkeys.Length; i++)
                lvwHotkeys.Items[i].SubItems[1].Text = HotKey.GetHotKeyString(hotkeys[i]);
            chkHotKey.Checked = StandardSetting.HotKey;
            chkMultimediaKeyboard.Checked = StandardSetting.MultimediaKeyboard;

            txtDspLocation.Text = FXSetting.DspLocation;

            initializing = false;
        }

        private Font String2Font(string value)
        {
            string[] dfont = value.Split(',');
            return new Font(dfont[0], float.Parse(dfont[1]), (FontStyle)(int.Parse(dfont[2])));
        }

        private string Font2String(Font value)
        {
            return value.Name + "," + value.Size.ToString() + "," + ((int)value.Style).ToString();
        }

        private void LyricShowPreview_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(picLBackColor.BackColor);

            Font font = (Font)lnkChooseLFont.Tag;
            Size s = e.Graphics.MeasureString("谷歌音乐盒", font).ToSize();
            e.Graphics.DrawString("谷歌音乐盒", font, new SolidBrush(picLTextColor.BackColor), new PointF(LyricShowPreview.Width / 2 - s.Width / 2, LyricShowPreview.Height / 2 - s.Height));
            e.Graphics.DrawString("谷歌音乐盒", font, new SolidBrush(picLHTextColor.BackColor), new PointF(LyricShowPreview.Width / 2 - s.Width / 2, LyricShowPreview.Height / 2));
        }

        private void DesktopLyricPreview_Paint(object sender, PaintEventArgs e)
        {
            Font font = (Font)lnkChooseDFont.Tag;
            Rectangle bounds = new Rectangle(0, 0, DesktopLyricPreview.Width - 1, DesktopLyricPreview.Height - 1);
            GraphicsPath gp = Helper.CreateRoundedRectangle(bounds, 5);

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            e.Graphics.FillPath(new SolidBrush(picDBackColor.BackColor), gp);
            e.Graphics.DrawPath(new Pen(picDBorderColor.BackColor), gp);

            string text = "谷歌音乐盒";
            Size s = this.CreateGraphics().MeasureString(text, font).ToSize();
            Bitmap backTextCache = new Bitmap(s.Width, s.Height);
            Bitmap foreTextCache = new Bitmap(s.Width, s.Height);
            Graphics gB = Graphics.FromImage(backTextCache);
            Graphics gF = Graphics.FromImage(foreTextCache);

            int[] linearmode = new int[] { 90, 0, 45, 135 };
            int lineMode = linearmode[cboDLinearMode.SelectedIndex];

            gB.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            gB.SmoothingMode = SmoothingMode.AntiAlias;
            gB.DrawString(text, font, new SolidBrush(Color.FromArgb(128, 0, 0, 0)), new PointF(1, 1));
            gB.DrawString(text, font, new LinearGradientBrush(new Rectangle(new Point(0, 0), backTextCache.Size), picDTextColor.Color0, picDTextColor.Color1, lineMode), new PointF(0, 0));

            gF.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            gF.SmoothingMode = SmoothingMode.AntiAlias;
            gF.DrawString(text, font, new SolidBrush(Color.FromArgb(128, 0, 0, 0)), new PointF(1, 1));
            gF.DrawString(text, font, new LinearGradientBrush(new Rectangle(new Point(0, 0), foreTextCache.Size), picDHTextColor.Color0, picDHTextColor.Color1, lineMode), new PointF(0, 0));

            gB.Dispose();
            gF.Dispose();

            Bitmap b = new Bitmap(DesktopLyricPreview.Width, DesktopLyricPreview.Height);
            Graphics g = Graphics.FromImage(b);
            Point offset = new Point(DesktopLyricPreview.Width / 2 - backTextCache.Width / 2, DesktopLyricPreview.Height / 2 - backTextCache.Height / 2);
            g.CompositingMode = CompositingMode.SourceCopy;

            int foreOffset = (int)(foreTextCache.Width * 0.5);
            g.DrawImage(backTextCache, offset);
            g.DrawImage(foreTextCache, new Rectangle(offset.X, DesktopLyricPreview.Height / 2 - foreTextCache.Height / 2, foreOffset, foreTextCache.Height), new Rectangle(0, 0, foreOffset, foreTextCache.Height), GraphicsUnit.Pixel);

            e.Graphics.DrawImage(b, new Point(0, 0));

            b.Dispose();
            g.Dispose();
            backTextCache.Dispose();
            foreTextCache.Dispose();
        }

        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            double size = 0;

            string path = Helper.GetCachePath(Helper.CacheType.Music, "");
            if (Directory.Exists(path)) size += GetSize(path);

            string end = "Bytes";
            if (size >= 1024)
            {
                size /= 1024;
                end = "KB";
                if (size >= 1024)
                {
                    size /= 1024;
                    end = "MB";
                    if (size >= 1024)
                    {
                        size /= 1024;
                        end = "GB";
                    }
                }
            }
            e.Result = Math.Round(size, 2).ToString() + " " + end;
        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            label35.Text = e.Result.ToString();
        }

        private long GetSize(string path)
        {
            DirectoryInfo di = new DirectoryInfo(path);
            if (!di.Exists) return 0;

            long size = 0;

            foreach (FileInfo f in di.GetFiles())
                size += f.Length;

            foreach (DirectoryInfo d in di.GetDirectories())
                size += GetSize(d.FullName);

            return size;
        }

        private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            bool yes = false;
            if (VTaskDialog.CanUseTankDialog())
            {
                if (VTaskDialog.ShowTaskDialog("清空缓存后将无法恢复，您确定要继续吗？", "提示", "您真的要清空缓存吗？",
                    VTaskDialog.TaskDialogButton.Yes | VTaskDialog.TaskDialogButton.No,
                    VTaskDialog.TaskDialogIcon.Warning) == VTaskDialog.TaskDialogResult.Yes) yes = true;
            }
            else
            {
                if (MessageBox.Show("清空缓存后将无法恢复，您确定要继续吗？", "您真的要清空缓存吗？",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) yes = true;
            }

            if (yes)
            {
                frmLoading f = new frmLoading();
                backgroundWorker2.RunWorkerAsync(f);
                f.ShowDialog();
            }
        }

        private void backgroundWorker2_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string path = Helper.GetCachePath(Helper.CacheType.Music, "");
            if (Directory.Exists(path)) DeleteDirectoryAndFiles(path);

            if (VTaskDialog.CanUseTankDialog())
                VTaskDialog.ShowTaskDialog("已成功清空缓存，为您节省了" + label35.Text + "的空间。", "提示", "操作已完成", VTaskDialog.TaskDialogButton.OK, VTaskDialog.TaskDialogIcon.Information);
            else
                MessageBox.Show("已成功清空缓存，为您节省了" + label35.Text + "的空间。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            e.Result = e.Argument;
        }

        private void backgroundWorker2_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            label35.Text = "0 Bytes";
            ((frmLoading)e.Result).Close();
        }

        private void DeleteDirectoryAndFiles(string path)
        {
            DirectoryInfo di = new DirectoryInfo(path);
            if (di.GetFiles().Length > 0)
                DeleteFiles(path);

            DirectoryInfo[] dis = di.GetDirectories();
            if (dis.Length > 0)
            {
                foreach (DirectoryInfo tempdi in dis)
                {
                    DeleteDirectoryAndFiles(tempdi.FullName);
                    if (tempdi.GetFiles().Length < 1 && tempdi.GetDirectories().Length < 1)
                        tempdi.Delete();
                }
            }
        }

        private void DeleteFiles(string path)
        {
            DirectoryInfo di = new DirectoryInfo(path);
            FileInfo[] fis = di.GetFiles();
            foreach (FileInfo fi in fis)
            {
                try { fi.Delete(); }
                catch { continue; }
            }
        }

        private void ChangeByCheckBox(object sender, EventArgs e)
        {
            if (initializing) return;
            CheckBox c = ((CheckBox)sender);
            string name = c.Name.Substring(3);
            string type = c.Tag.ToString();
            if (type == "Standard") StandardSetting.Data[name] = c.Checked.ToString();
            else if (type == "LyricShow") LyricShowSetting.Data[name] = c.Checked.ToString();

            if (name == "TopMost")
            {
                fm.TopMost = c.Checked;
                fm.fder.TopMost = c.Checked;
                fm.feq.TopMost = c.Checked;
                this.TopMost = c.Checked;
            }
            else if (name == "ShowAd")
            {
                if (c.Checked)
                    fm.webBrowser1.Navigate("http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-1045560459139079&output=html&h=90&slotname=4784027349&w=728&ea=0&flash=10.1.82&hints=%E6%B3%A8%E5%86%8C%20%E4%B8%AD%E6%96%87%20%E8%A7%86%E9%A2%91%20%E6%8A%80%E6%9C%AF%20%E5%A4%A7%E5%AD%A6%20%E8%AE%BA%E5%9D%9B%20%E6%97%85%E6%B8%B8%20%E8%82%A1%E7%A5%A8%20%E7%95%99%E5%AD%A6%20%E5%87%BA%E5%9B%BD%20%E7%A7%BB%E6%B0%91%20nba%20bt%20cctv%203g%20mac%20ie%20windows%20microsoft%20download&url=top100.cn&dt=1282102196127&shv=r20100804&correlator=1282102196132&dblk=1&frm=1&adk=342823052&ga_vid=1441465170.1282102196&ga_sid=1282102196&ga_hid=1240411935&ga_fc=0&u_tz=480&u_his=2&u_java=1&u_h=800&u_w=1280&u_ah=760&u_aw=1280&u_cd=32&u_nplug=19&u_nmime=70&biw=-12245933&bih=-12245933&ifk=1151587861&loc=http://www.google.cn/music/top100/player_page&fu=0&ifi=1&dtd=35");
                else fm.webBrowser1.Navigate("about:blank");
                fm.ClientSize = new System.Drawing.Size(740, (c.Checked ? 570 : 468));
            }
            else if (sender == chkHotKey || sender == chkMultimediaKeyboard)
                fm.InitializeHotkeys();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cboCloseEvent_SelectedIndexChanged(object sender, EventArgs e)
        {
            StandardSetting.CloseEvent = cboCloseEvent.SelectedIndex;
        }

        private void cboProfileLocation_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboProfileLocation.SelectedIndex == 0)
            {
                if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GMusicBox" + "\\true"))
                    Program.CreatHiddenProfile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GMusicBox" + "\\true");
            }
            else if (cboProfileLocation.SelectedIndex == 1)
            {
                if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GMusicBox" + "\\true"))
                    File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GMusicBox" + "\\true");
            }
        }

        private void nudCacheMax_ValueChanged(object sender, EventArgs e)
        {
            StandardSetting.CacheMax = (int)nudCacheMax.Value;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            StandardSetting.CachePath = txtMusicCache.Text;
            StandardSetting.Save();
            LyricShowSetting.Save();
        }

        private void picSelectColor(object sender, EventArgs e)
        {
            PictureBox pb = (PictureBox)sender;
            ColorDialog cd = new ColorDialog();
            cd.Color = pb.BackColor;
            if (cd.ShowDialog() == DialogResult.OK)
            {
                pb.BackColor = cd.Color;
                LyricShowSetting.Data[pb.Name.Substring(3)] = Helper.Color2String(pb.BackColor);

                fm.lyricShow1.fdl.ClearCache();
                fm.lyricShow1.RefreshDesktopLyric();
                LyricShowPreview.Invalidate();
                DesktopLyricPreview.Invalidate();
            }
        }

        private void ColorPicker_ColorChanged(object sender, EventArgs e)
        {
            ColorPicker cp = (ColorPicker)sender;
            LyricShowSetting.Data[cp.Name.Substring(3)] = Helper.Color2String(cp.Color0);
            LyricShowSetting.Data[cp.Name.Substring(3) + "1"] = Helper.Color2String(cp.Color1);

            fm.lyricShow1.fdl.ClearCache();
            fm.lyricShow1.RefreshDesktopLyric();
            LyricShowPreview.Invalidate();
            DesktopLyricPreview.Invalidate();
        }

        private void ChooseFont(object sender, EventArgs e)
        {
            LinkLabel lnk = (LinkLabel)sender;
            FontDialog fd = new FontDialog();
            fd.Font = (Font)lnk.Tag;
            if (fd.ShowDialog() == DialogResult.OK)
            {
                lnk.Tag = fd.Font;
                LyricShowSetting.Data[lnk.Name.Substring(9)] = Font2String(fd.Font);

                fm.lyricShow1.fdl.ClearCache();
                fm.lyricShow1.UpdateSkin();
                fm.lyricShow1.RefreshDesktopLyric();
                LyricShowPreview.Invalidate();
                DesktopLyricPreview.Invalidate();
            }
        }

        private void lvwHotkeys_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvwHotkeys.SelectedItems.Count != 0)
            {
                hotKeyTextBox1.SetKey(hotkeys[lvwHotkeys.SelectedItems[0].Index]);
                hotKeyTextBox1.Focus();
            }
        }

        private void btnHotKeyApply_Click(object sender, EventArgs e)
        {
            if (lvwHotkeys.SelectedItems.Count == 0)
            {
                if (VTaskDialog.CanUseTankDialog())
                    VTaskDialog.ShowTaskDialog("您还没有选中一个需要更改的热键，请选选择一个需要修改的热键。", "提示", "无法更改热键", VTaskDialog.TaskDialogButton.OK, VTaskDialog.TaskDialogIcon.Warning);
                else MessageBox.Show("您还没有选中一个需要更改的热键，请选选择一个需要修改的热键。", "无法更改热键", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string s = "";
                s += hotKeyTextBox1.Ctrl.ToString() + ",";
                s += hotKeyTextBox1.Shift.ToString() + ",";
                s += hotKeyTextBox1.Alt.ToString() + ",";
                s += ((int)hotKeyTextBox1.Key).ToString();
                hotkeys[lvwHotkeys.SelectedItems[0].Index] = s;
                lvwHotkeys.SelectedItems[0].SubItems[1].Text = hotKeyTextBox1.Text;

                string hks = "";
                for (int i = 0; i < lvwHotkeys.Items.Count; i++)
                    hks += hotkeys[i] + "|";
                hks = hks.Substring(0, hks.Length - 1);
                StandardSetting.HotKeys = hks;
                fm.InitializeHotkeys();
            }
        }

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!dspRefresh)
                RefreshDspList();
        }

        private void RefreshDspList()
        {
            dspRefresh = false;
            lvwDSP.Items.Clear();
            WINAMP_DSP.PlugIns.Clear();
            WINAMP_DSP.FindPlugins(FXSetting.DspLocation);
            for (int i = 0; i < WINAMP_DSP.PlugIns.Count; i++)
            {
                string[] s = new string[] { WINAMP_DSP.PlugIns[i].Description, Path.GetFileName(WINAMP_DSP.PlugIns[i].File) };
                ListViewItem lvi = new ListViewItem(s);
                lvi.Tag = WINAMP_DSP.PlugIns[i].File;

                if (fm.be.FindDSP(s[1]) != -1) lvi.Checked = true;
                lvwDSP.Items.Add(lvi);
            }
            dspRefresh = true;
        }

        private void lvwDSP_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            if (!dspRefresh) return;
            int dspIndex = fm.be.FindDSP(e.Item.SubItems[1].Text);
            if (!e.Item.Checked && dspIndex != -1)
                fm.be.RemoveDSP(dspIndex);
            else if (e.Item.Checked && dspIndex == -1)
                fm.be.AddDSP(e.Item.Tag.ToString());

            List<string> dsp = new List<string>();
            foreach(ListViewItem item in lvwDSP.CheckedItems)
                dsp.Add(item.Tag.ToString());
            FXSetting.EnabledDsp = dsp.ToArray(); FXSetting.Save();
        }

        private void btnDSPConfig_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lvwDSP.SelectedItems)
            {
                int index = fm.be.FindDSP(item.SubItems[1].Text);
                if (index == -1) continue;
                fm.be.ConfigDSP(index);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "请选择插件目录：";
            fbd.SelectedPath = txtDspLocation.Text;
            fbd.ShowNewFolderButton = false;
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                txtDspLocation.Text = fbd.SelectedPath;
                FXSetting.DspLocation = txtDspLocation.Text;
                FXSetting.Save();
                RefreshDspList();
            }
        }

        private void btnMusicCache_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "请选择缓存目录：";
            fbd.SelectedPath = Helper.GetCachePath(Helper.CacheType.Lyric, txtMusicCache.Text);
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                txtMusicCache.Text = fbd.SelectedPath.Replace(Settings.SettingSavePath, "");
                StandardSetting.CachePath = txtMusicCache.Text;
                StandardSetting.Save();
            }
        }

        private void btnDefault_Click(object sender, EventArgs e)
        {
            StandardSetting.Data = new Settings();
            LyricShowSetting.Data = new Settings();
            Initialize();

            picDHTextColor.Invalidate();
            picDTextColor.Invalidate();
            fm.TopMost = chkTopMost.Checked;
            fm.fder.TopMost = chkTopMost.Checked;
            fm.feq.TopMost = chkTopMost.Checked;

            if (chkShowAd.Checked)
                fm.webBrowser1.Navigate("http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-1045560459139079&output=html&h=90&slotname=4784027349&w=728&ea=0&flash=10.1.82&hints=%E6%B3%A8%E5%86%8C%20%E4%B8%AD%E6%96%87%20%E8%A7%86%E9%A2%91%20%E6%8A%80%E6%9C%AF%20%E5%A4%A7%E5%AD%A6%20%E8%AE%BA%E5%9D%9B%20%E6%97%85%E6%B8%B8%20%E8%82%A1%E7%A5%A8%20%E7%95%99%E5%AD%A6%20%E5%87%BA%E5%9B%BD%20%E7%A7%BB%E6%B0%91%20nba%20bt%20cctv%203g%20mac%20ie%20windows%20microsoft%20download&url=top100.cn&dt=1282102196127&shv=r20100804&correlator=1282102196132&dblk=1&frm=1&adk=342823052&ga_vid=1441465170.1282102196&ga_sid=1282102196&ga_hid=1240411935&ga_fc=0&u_tz=480&u_his=2&u_java=1&u_h=800&u_w=1280&u_ah=760&u_aw=1280&u_cd=32&u_nplug=19&u_nmime=70&biw=-12245933&bih=-12245933&ifk=1151587861&loc=http://www.google.cn/music/top100/player_page&fu=0&ifi=1&dtd=35");
            else fm.webBrowser1.Navigate("about:blank");
            fm.ClientSize = new System.Drawing.Size(740, (chkShowAd.Checked ? 570 : 468));

            fm.InitializeHotkeys();
            fm.lyricShow1.fdl.ClearCache();
            fm.lyricShow1.RefreshDesktopLyric();
            LyricShowPreview.Invalidate();
            DesktopLyricPreview.Invalidate();

            this.Activate();
        }

        private void cboDLinearMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (initializing) return;
            LyricShowSetting.DLinearMode = cboDLinearMode.SelectedIndex;

            fm.lyricShow1.fdl.ClearCache();
            LyricShowPreview.Invalidate();
            DesktopLyricPreview.Invalidate();
        }

        private void cboDOpacity_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (initializing) return;
            LyricShowSetting.DOpacity = double.Parse(cboDOpacity.Text.Replace("%", "")) / 100;
            fm.lyricShow1.UpdateSkin();
            fm.lyricShow1.fdl.ClearCache();
            fm.lyricShow1.RefreshDesktopLyric();
        }
    }
}
